$(function () {
    let form = layui.form;
    let layer = layui.layer;
    form.verify({
        pwd: [
            /^[\S]{6,15}$/,
            "密码的长度为6-15个字符，且不能包含空格",
        ],
        //新密码校验规则
        newpwd: function (value) {
            if ($("[name=oldPwd]").val() == value) return '新密码不能与原密码相同!'
        },
        //确认新密码校验规则
        renewpwd: function (value) {
            if ($("[name=newPwd]").val() !== value) return '两次输入密码不一致!'
        }
    })

    $("#form-userpwd").on('submit', function (e) {
        e.preventDefault();
        axios({
            method: 'POST',
            url: "/my/updatepwd",
            data: $(this).serialize()
        }).then((res) => {
            //console.log(res);
            let obj = res.data;
            if (obj.status !== 0) return layer.msg(obj.message);
            layer.msg('密码修改成功!');
            $("#form-userpwd")[0].reset()
        })
    })


})